package com.mtt.erp.logistics.controller;


import com.mtt.erp.common.api.R;
import com.mtt.erp.common.api.ResultCode;
import com.mtt.erp.common.controller.BaseController;
import com.mtt.erp.common.domain.MttErpResponse;
import com.mtt.erp.common.exception.MttErpException;
import com.mtt.erp.logistics.domain.OrderFaceTemplete;
import com.mtt.erp.logistics.service.IOrderFaceTempleteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotBlank;

/**
 * @author
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/orderTemplate")
@Api(value = "电子面单模板", tags = "M008-物流-电子面单模板管理接口")
public class OrderFaceTempleteController {

    @Autowired
    private IOrderFaceTempleteService iOrderFaceTempleteService;
    /**
     * 按orderCode 查询电子面单模板
     * @param orderCode
     * @return
     */
    @GetMapping("/{orderCode}")
    @ApiOperation(value = "电子面单", notes = "传入orderCode")
    @ApiImplicitParams({
            @ApiImplicitParam(name="orderCode",value="订单编号",required=true,paramType = "path")
    })
    public R<OrderFaceTemplete> findOrderFacetemplate(@NotBlank(message = "required") @PathVariable String orderCode) throws MttErpException {
        OrderFaceTemplete orderFaceTemp=this.iOrderFaceTempleteService.findByOrderCode(orderCode);
        if(orderFaceTemp==null){
            return R.fail(ResultCode.NO_CONTENT);
        }else{
            return R.data(orderFaceTemp);
        }

    }



    @GetMapping("/test/{orderCode}")
    @ApiOperation(value = "SwaggerDemo电子面单", notes = "传入orderCode", position = 1)
    @ApiImplicitParams({
            @ApiImplicitParam(name="orderCode",value="订单编号",required=true,paramType = "path")
    })
    public R<OrderFaceTemplete> findOrderFacetemplateTest(@NotBlank(message = "required") @PathVariable String orderCode) throws MttErpException {
        OrderFaceTemplete orderFaceTemp=this.iOrderFaceTempleteService.findByOrderCode(orderCode);
        if(orderFaceTemp==null){
            return R.fail(ResultCode.NO_CONTENT);
        }else{
            return R.data(orderFaceTemp);
        }

    }








}
